"use strict";
cc._RF.push(module, 'af1e9On/bNAQ7bwi+oaSrAn', 'CommonUI');
// scripts/common/components/CommonUI.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var EventManager_1 = require("../../../eazax-ccc/core/EventManager");
var PopupManager_1 = require("../../../eazax-ccc/core/PopupManager");
var SceneNavigator_1 = require("../../../eazax-ccc/core/SceneNavigator");
var CaseManager_1 = require("../CaseManager");
var Constants_1 = require("../constants/Constants");
var CustomEvents_1 = require("../constants/CustomEvents");
var Toast_1 = require("./Toast");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var CommonUI = /** @class */ (function (_super) {
    __extends(CommonUI, _super);
    function CommonUI() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.homeBtn = null;
        _this.titleTip = null;
        return _this;
    }
    CommonUI.prototype.onLoad = function () {
        this.init();
        this.registerEvent();
    };
    CommonUI.prototype.start = function () {
        this.reset();
    };
    CommonUI.prototype.onEnable = function () {
        this.onCaseSwitch();
    };
    CommonUI.prototype.onDestroy = function () {
        this.unregisterEvent();
    };
    /**
     * 订阅事件
     */
    CommonUI.prototype.registerEvent = function () {
        // 点击
        this.homeBtn.on(cc.Node.EventType.TOUCH_END, this.onHomeBtnClick, this);
        this.titleTip.on(cc.Node.EventType.TOUCH_END, this.onTitleTipClick, this);
        // 切换
        EventManager_1.default.on(CustomEvents_1.CHANGE_SCENE, this.onSceneChange, this);
        EventManager_1.default.on(CustomEvents_1.SWITCH_CASE, this.onCaseSwitch, this);
    };
    /**
     * 取消事件订阅
     */
    CommonUI.prototype.unregisterEvent = function () {
        // 切换
        EventManager_1.default.off(CustomEvents_1.CHANGE_SCENE, this.onSceneChange, this);
        EventManager_1.default.off(CustomEvents_1.SWITCH_CASE, this.onCaseSwitch, this);
    };
    /**
     * 初始化
     */
    CommonUI.prototype.init = function () {
        // 设为常驻节点
        cc.game.addPersistRootNode(this.node);
        // 弹窗容器
        PopupManager_1.default.container = this.node;
    };
    /**
     * 重置
     */
    CommonUI.prototype.reset = function () {
        this.titleTip.active = true;
    };
    /**
     * 首页按钮点击回调
     */
    CommonUI.prototype.onHomeBtnClick = function () {
        CaseManager_1.default.goHome();
    };
    /**
     * 提示点击回调
     */
    CommonUI.prototype.onTitleTipClick = function () {
        // this.titleTip.active = false;
        Toast_1.default.show('别点我，点我啥用？');
    };
    /**
     * 场景切换回调
     */
    CommonUI.prototype.onSceneChange = function () {
    };
    /**
     * 示例切换回调
     */
    CommonUI.prototype.onCaseSwitch = function () {
        cc.log(SceneNavigator_1.default.curScene, Constants_1.SceneName.Home);
        this.homeBtn.active = (SceneNavigator_1.default.curScene !== Constants_1.SceneName.Home);
    };
    __decorate([
        property(cc.Node)
    ], CommonUI.prototype, "homeBtn", void 0);
    __decorate([
        property(cc.Node)
    ], CommonUI.prototype, "titleTip", void 0);
    CommonUI = __decorate([
        ccclass
    ], CommonUI);
    return CommonUI;
}(cc.Component));
exports.default = CommonUI;

cc._RF.pop();